<?php
// Get current slider
$current = BanditSliders::get_current_slider();
$slider = $current?BanditSliders::get_slider($current):FALSE;
$url = FEATHER_THEME_URL.'modules/bandit-sliders/';
?>

	
<div id="nav-menus-frame">

	<!-- ######  Sidebar ###### -->	
	<div id="menu-settings-column" class="metabox-holder">
			<div id="side-sortables" class="meta-box-sortables bandit-slider-sidebar">
			
			<form id="nav-menu-meta" action="options.php" method="post">
			<?php settings_fields('bandit-slider-settings'); ?>
				<div class="postbox">
					<div class="handlediv" title="Click to toggle"><br></div>
					<h3 class="hndle">Create New Slider</h3>
					
					<div class="inside">
						<div class="bandit-slider-new">
							<p id="menu-item-name-wrap">
								<label class="howto" for="slider-name">
									<span>Label</span>
									<input id="slider-name" name="bandit_slider[name]" type="text" class="regular-text menu-item-textbox" maxlength="30">
								</label>
							</p>
							<p class="button-controls">
								<span class="add-to-menu">
									<img class="waiting" src="<?php echo admin_url(); ?>/images/wpspin_light.gif" alt="">
									<input type="hidden" name="bandit_slider[action]" value="new" />
									<input type="submit" id="bandit-slider-submit" class="button-secondary submit-add-to-menu" value="Add Slider">
								</span>
							</p>
						</div>
					</div><!-- #inside -->
				</div><!-- #postbox -->
			</form>

<?php if($slider): ?>
			<form id="nav-menu-meta" action="options.php" method="post">
			<?php settings_fields('bandit-slider-settings'); ?>
				<div class="postbox">
					<div class="handlediv" title="Click to toggle"><br></div>
					<h3 class="hndle">Add Image Item</h3>
					
					<div class="inside">
						<div class="bandit-slider-add-image">
							<p id="menu-item-name-wrap">
								<label class="howto" for="slider-item-caption">
									<span>Caption</span>
									<input id="slider-item-caption" name="bandit_slider[caption]" type="text" class="regular-text menu-item-textbox">
								</label>
							</p>
							<p id="menu-item-name-wrap">
								<label class="howto" for="slider-item-link">
									<span>Link</span>
									<input id="slider-item-link" name="bandit_slider[link]" type="text" class="regular-text menu-item-textbox">
								</label>
							</p>
							<p id="menu-item-name-wrap">
								<label class="howto" for="slider-item-image">
									<span>Image</span>
									<input id="slider-item-image" name="bandit_slider[image]" type="text" class="regular-text menu-item-textbox">
								</label>
							</p>
							<p id="menu-item-name-wrap">
								<label class="howto" for="slider-item-image-alt">
									<span>Image Alt</span>
									<input id="slider-item-image-alt" name="bandit_slider[image_alt]" type="text" class="regular-text menu-item-textbox">
								</label>
							</p>
							<p class="button-controls">
								<a href="#" class="bandit-item-select-image">Select Image</a>
								<span class="add-to-menu">
									<img class="waiting" src="<?php echo admin_url('images/wpspin_light.gif'); ?>" alt="">
									<input type="hidden" name="bandit_slider[action]" value="add_image" />
									<input type="hidden" name="bandit_slider[slider]" value="<?php echo $current; ?>" />
									<input type="submit" id="bandit-item-image-submit" class="button-secondary submit-add-to-menu" value="Add Item">
								</span>
							</p>
						</div>
					</div><!-- /#inside -->
				</div><!-- /#postbox -->
			</form>
<?php endif; ?>
						
			</div><!-- /#side-sortables -->
		</form><!-- /form -->
	</div><!-- /.metabox-holder -->
	<!-- ######  End Sidebar ###### -->



	<div id="menu-management-liquid">
		<div id="menu-management">

			<div class="nav-tabs-nav">
				<div class="nav-tabs-arrow nav-tabs-arrow-left" style="display: none; "><a>«</a></div>
				<div class="nav-tabs-wrapper">
					<div class="nav-tabs">
						<?php BanditSliders::nav_tabs(); ?>
					</div>
				</div>
				<div class="nav-tabs-arrow nav-tabs-arrow-right" style="display: none; "><a>»</a></div>
			</div>

			<div class="menu-edit">
				<form action="options.php" method="post">
				<?php settings_fields('bandit-slider-settings'); ?>

<?php if($slider): ?>
					<div id="nav-menu-header">
						<div id="submitpost" class="submitbox">
							<div class="major-publishing-actions">
								<label class="menu-name-label howto open-label" for="menu-name">
									<span>Name</span>
									<input name="bandit_slider[name]" type="text" class="menu-name regular-text menu-item-textbox" title="Enter menu name here" value="<?php echo $slider['name']; ?>">
								</label>
																
								<br class="clear">
								<div class="publishing-action">
									<input type="submit" class="button-primary menu-save" value="Save Slider">
								</div><!-- /.publishing-action -->

								<div class="delete-action">
									<a class="submitdelete deletion bandit-slider-delete-link" href="#">Delete Slider</a>
								</div><!-- /.delete-action -->
							</div><!-- /.major-publishing-actions -->
						</div><!-- /#submitpost .submitbox -->
					</div><!-- /#nav-menu-header -->
<?php endif; ?>


					<div id="post-body">
						<div id="post-body-content">
							<div id="menu-instructions" class="post-body-plain">

								<?php if(!isset($slider['items'])): ?>

									<p class="empty-message">No items have been added.</p>

								<?php else: ?>

								<table class="bandit-slider-table" cellpadding="0" cellspacing="0">
									<thead>
										<tr>
											<th class="image">Image</th>
											<th class="image-alt">Image Alt</th>
											<th class="caption">Caption</th>
											<th class="link">Link</th>
											<th class="actions"></th>
										</tr>
									</thead>
									<tbody class="sortable">
										<?php foreach($slider['items'] as $key=>$item): ?>
										<tr>
											<td class="image">
												<?php echo wp_get_attachment_image($item['image_id'],'thumbnail'); ?>
												<input class="bandit_image_field" name="bandit_slider[items][<?php echo $key; ?>][image]" type="hidden" class="code" value="<?php echo $item['image']; ?>">
											</td>
											<td class="image-alt">
												<input name="bandit_slider[items][<?php echo $key; ?>][image_alt]" type="text" class="code" value="<?php echo $item['image_alt']; ?>">
											</td>
											<td class="caption">
												<input name="bandit_slider[items][<?php echo $key; ?>][caption]" type="text" class="code" value="<?php echo $item['caption']; ?>">
											</td>
											<td class="link">
												<input name="bandit_slider[items][<?php echo $key; ?>][link]" type="text" class="code" value="<?php echo $item['link']; ?>">
											</td>
											<td class="actions">
												<a href="#" class="bandit-link-move"><img src="<?php echo $url; ?>/img/move.png" alt="Move" title="Drag to Move" /></a>
												<a href="#" class="bandit-link-delete"><img src="<?php echo $url; ?>/img/delete.png" alt="Delete" /></a>
											</td>
										</tr>
										<?php endforeach; ?>
									</tbody>
								</table>

								<?php endif; ?>

							</div>
						</div><!-- /#post-body-content -->
					</div><!-- /#post-body -->


					<div id="nav-menu-footer">
						<div class="major-publishing-actions">
							<div class="publishing-action">
								<input type="hidden" name="bandit_slider[action]" value="update" />
								<input type="hidden" name="bandit_slider[slider]" value="<?php echo $current; ?>" />
								<input type="submit" class="button-primary menu-save" value="Save Slider">
							</div>
						</div>
					</div><!-- /#nav-menu-footer -->
				</form><!-- /#update-nav-menu -->
			</div><!-- /.menu-edit -->
		</div><!-- /#menu-management -->
	</div><!-- /#menu-management-liquid -->

<?php if($slider): ?>
	<form id="bandit-slider-delete" action="options.php" method="post">
		<?php settings_fields('bandit-slider-settings'); ?>
		<input type="hidden" name="bandit_slider[slider]" value="<?php echo $current; ?>" />
		<input type="hidden" name="bandit_slider[action]" value="delete" />
	</form>
<?php endif; ?>
	
</div><!-- /#nav-menus-frame -->
